<?php 
//生成器
//使用生成器打印fizzbuzz序列
function fizzbuzz($start, $end)
{
    $current = $start;
    while ($current <= $end) {
        if ($current%3 == 0 && $current%5 == 0) {
            yield "3和5的倍数";
        } 

        if ($current%3 == 0) {
            yield "3的倍数";
        }

        if ($current%5 == 0) {
            yield "5的倍数";
        } 
            yield $current;
        

        $current++;
    }  
}

foreach(fizzbuzz(1, 20) as $number) {
    echo $number.'<br />';
}
?>